<?php namespace App\Exceptions;
/**
 * Created by PhpStorm.
 * User: jolly
 * Date: 2015/8/4
 * Time: 11:50
 */
use Exception;

class SignInException extends Exception{
    const UsernameNotExists = 0x01;
    const EmailNotExists = 0x02;
    const PhoneNotExists = 0x03;
    const PasswordNotMatch = 0x04;

    public function __construct($code,array $data = [],Exception $previous = null){
        switch ($code){
            case self::UsernameNotExists:
                $message = trans('用户名不存在！',['username' => array_get($data,'username')]);
                break;
            case self::EmailNotExists:
                $message = trans('用户邮箱不存在！',['email' => array_get($data,'email')]);
                break;
            case self::PhoneNotExists:
                $message = trans('用户电话号码不存在！',['phone' => array_get($data,'phone')]);
                break;
            case self::PasswordNotMatch:
                $message = trans('用户密码不匹配！');
                break;
            default:
                $message = trans('未知错误！');
                break;
        }

        parent::__construct($message,$code,$previous);
    }
}